home *** CD-ROM | disk | FTP | other *** search
- From: genrad!decvax!minow (Martin Minow)
- Subject: MicroEmacs (Part 5 of 6)
- Newsgroups: mod.sources
- Approved: jpn@panda.UUCP
-
- Mod.sources: Volume 4, Issue 72
- Submitted by: decvax!minow (Martin Minow)
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # tty
- # This archive created: Sun Apr 13 11:18:12 1986
- export PATH; PATH=/bin:$PATH
- if test ! -d 'tty'
- then
- echo shar: creating directory "'tty'"
- mkdir 'tty'
- fi
- if test ! -d 'tty/ansi'
- then
- echo shar: creating directory "'tty/ansi'"
- mkdir 'tty/ansi'
- fi
- echo shar: extracting "'tty/ansi/tty.c'" '(7315 characters)'
- if test -f 'tty/ansi/tty.c'
- then
- echo shar: will not over-write existing file "'tty/ansi/tty.c'"
- else
- cat << \SHAR_EOF > 'tty/ansi/tty.c'
- /*
- * Name: MicroEMACS
- * Digital ANSI terminal display
- * Version: 29
- * Last edit: 10-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- *
- * The SCALD display is just an ANSI display, with
- * some special hacks to kludge around the bugs, and
- * to make it a bit more friendly. The support is
- * unquestionably non-optimal. The costs are wrong; in
- * fact, display should be fixed up to understand non
- * linear cost devices like the SCALD. The BackIndex
- * sequence used in the insert line is defective in
- * the display firmware, so we set the cost high to
- * discourage its use. Perhaps the cost should be
- * set to infinity!
- */
- #include "def.h"
-
- #define SCALD 0 /* Buggy display. */
-
- #define BEL 0x07 /* BEL character. */
- #define ESC 0x1B /* ESC character. */
- #define LF 0x0A /* Line feed. */
-
- extern int ttrow;
- extern int ttcol;
- extern int tttop;
- extern int ttbot;
- extern int tthue;
-
- #if SCALD
-
- int tceeol = 3; /* Costs, SCALDstation. */
- int tcinsl = 100;
- int tcdell = 100;
-
- #else
-
- int tceeol = 3; /* Costs, ANSI display. */
- int tcinsl = 17;
- int tcdell = 16;
-
- #endif
-
- /*
- * Initialize the terminal when the editor
- * gets started up. This is a no-op on the ANSI
- * display. On the SCALD display, it turns off the
- * half-screen scroll, because this appears to really
- * confuse the scrolling region firmware in the
- * display.
- */
- ttinit()
- {
- #if SCALD
- ttputc(ESC); /* Cancel jump interval. */
- ttputc('[');
- asciiparm(1);
- ttputc('j');
- #endif
- }
-
- /*
- * Clean up the terminal, in anticipation of
- * a return to the command interpreter. This is a no-op
- * on the ANSI display. On the SCALD display, it sets the
- * window back to half screen scrolling. Perhaps it should
- * query the display for the increment, and put it
- * back to what it was.
- */
- tttidy()
- {
- #if SCALD
- ttputc(ESC); /* Half screen. */
- ttputc('[');
- asciiparm(nrow/2);
- ttputc('j');
- #endif
- }
-
- /*
- * Move the cursor to the specified
- * origin 0 row and column position. Try to
- * optimize out extra moves; redisplay may
- * have left the cursor in the right
- * location last time!
- */
- ttmove(row, col)
- {
- if (ttrow!=row || ttcol!=col) {
- ttputc(ESC);
- ttputc('[');
- asciiparm(row+1);
- ttputc(';');
- asciiparm(col+1);
- ttputc('H');
- ttrow = row;
- ttcol = col;
- }
- }
-
- /*
- * Erase to end of line.
- */
- tteeol()
- {
- ttputc(ESC);
- ttputc('[');
- ttputc('K');
- }
-
- /*
- * Erase to end of page.
- */
- tteeop()
- {
- ttputc(ESC);
- ttputc('[');
- ttputc('J');
- }
-
- /*
- * Make a noise.
- */
- ttbeep()
- {
- ttputc(BEL);
- ttflush();
- }
-
- /*
- * Convert a number to decimal
- * ascii, and write it out. Used to
- * deal with numeric arguments.
- */
- asciiparm(n)
- register int n;
- {
- register int q;
-
- q = n/10;
- if (q != 0)
- asciiparm(q);
- ttputc((n%10) + '0');
- }
-
- /*
- * Insert a block of blank lines onto the
- * screen, using a scrolling region that starts at row
- * "row" and extends down to row "bot". Deal with the one
- * line case, which is a little bit special, with special
- * case code. Put all of the back index commands out
- * in a block. The SCALDstation loses the position
- * of the cursor.
- */
- ttinsl(row, bot, nchunk)
- {
- if (row == bot) { /* Funny case. */
- if (nchunk != 1)
- abort();
- ttmove(row, 0);
- tteeol();
- } else { /* General case. */
- ttwindow(row, bot);
- ttmove(row, 0);
- while (nchunk--) {
- ttputc(ESC); /* Back index. */
- ttputc('M');
- }
- #if SCALD
- ttrow = HUGE;
- ttcol = HUGE;
- #endif
- }
- }
-
- /*
- * Delete a block of lines, with the uppermost
- * line at row "row", in a screen slice that extends to
- * row "bot". The "nchunk" is the number of lines that have
- * to be deleted. Watch for the pathalogical 1 line case,
- * where the scroll region is *not* the way to do it.
- * The block delete is used by the slightly more
- * optimal display code.
- */
- ttdell(row, bot, nchunk)
- {
- if (row == bot) { /* Funny case. */
- if (nchunk != 1)
- abort();
- ttmove(row, 0);
- tteeol();
- } else { /* General case. */
- ttwindow(row, bot);
- ttmove(bot, 0);
- while (nchunk--)
- ttputc(LF);
- #if SCALD
- ttrow = HUGE;
- ttcol = HUGE;
- #endif
- }
- }
-
- /*
- * This routine sets the scrolling window
- * on the display to go from line "top" to line
- * "bot" (origin 0, inclusive). The caller checks
- * for the pathalogical 1 line scroll window that
- * doesn't work right, and avoids it. The "ttrow"
- * and "ttcol" variables are set to a crazy value
- * to ensure that the next call to "ttmove" does
- * not turn into a no-op (the window adjustment
- * moves the cursor).
- */
- ttwindow(top, bot)
- {
- if (tttop!=top || ttbot!=bot) {
- ttputc(ESC);
- ttputc('[');
- asciiparm(top+1);
- ttputc(';');
- asciiparm(bot+1);
- ttputc('r');
- ttrow = HUGE; /* Unknown. */
- ttcol = HUGE;
- tttop = top; /* Remember region. */
- ttbot = bot;
- }
- }
-
- /*
- * Switch to full screen scroll. This is
- * used by "spawn.c" just before is suspends the
- * editor, and by "display.c" when it is getting ready
- * to exit. This function gets to full screen scroll
- * by sending a DECSTBM with default parameters, but
- * I think that this is wrong. The SRM seems to say
- * that the default for Pb is 24, not the size of the
- * screen, which seems really dumb. Do I really have
- * to read the size of the screen as in "ttresize"
- * to do this right?
- */
- ttnowindow()
- {
- ttputc(ESC);
- ttputc('[');
- ttputc(';');
- ttputc('r');
- ttrow = HUGE; /* Unknown. */
- ttcol = HUGE;
- tttop = HUGE; /* No scroll region. */
- ttbot = HUGE;
- }
-
- /*
- * Set the current writing color to the
- * specified color. Watch for color changes that are
- * not going to do anything (the color is already right)
- * and don't send anything to the display.
- * The rainbow version does this in putline.s on a
- * line by line basis, so don't bother sending
- * out the color shift.
- */
- ttcolor(color)
- register int color;
- {
- if (color != tthue) {
- /*
- if !RAINBOW
- */
- if (color == CTEXT) { /* Normal video. */
- ttputc(ESC);
- ttputc('[');
- ttputc('m');
- } else if (color == CMODE) { /* Reverse video. */
- ttputc(ESC);
- ttputc('[');
- ttputc('7');
- ttputc('m');
- }
- /*
- endif
- */
- tthue = color; /* Save the color. */
- }
- }
-
- /*
- * This routine is called by the
- * "refresh the screen" command to try and resize
- * the display. The new size, which must be deadstopped
- * to not exceed the NROW and NCOL limits, it stored
- * back into "nrow" and "ncol". Display can always deal
- * with a screen NROW by NCOL. Look in "window.c" to
- * see how the caller deals with a change.
- */
- ttresize()
- {
- register int c;
- register int newnrow;
- register int newncol;
-
- ttputc(ESC); /* Off the end of the */
- ttputc('['); /* world. The terminal */
- asciiparm(HUGE); /* will chop it. */
- ttputc(';');
- asciiparm(HUGE);
- ttputc('H');
- ttrow = HUGE; /* Unknown. */
- ttcol = HUGE;
- ttputc(ESC); /* Report position. */
- ttputc('[');
- ttputc('6');
- ttputc('n');
- ttflush();
- if (ttgetc()!=ESC || ttgetc()!='[')
- return;
- newnrow = 0;
- while ((c=ttgetc())>='0' && c<='9')
- newnrow = 10*newnrow + c - '0';
- if (c != ';')
- return;
- newncol = 0;
- while ((c=ttgetc())>='0' && c<='9')
- newncol = 10*newncol + c - '0';
- if (c != 'R')
- return;
- if (newnrow < 1) /* Check limits. */
- newnrow = 1;
- else if (newnrow > NROW)
- newnrow = NROW;
- if (newncol < 1)
- newncol = 1;
- else if (newncol > NCOL)
- newncol = NCOL;
- nrow = newnrow;
- ncol = newncol;
- }
- SHAR_EOF
- if test 7315 -ne "`wc -c < 'tty/ansi/tty.c'`"
- then
- echo shar: error transmitting "'tty/ansi/tty.c'" '(should have been 7315 characters)'
- fi
- fi
- echo shar: extracting "'tty/ansi/ttydef.h'" '(1285 characters)'
- if test -f 'tty/ansi/ttydef.h'
- then
- echo shar: will not over-write existing file "'tty/ansi/ttydef.h'"
- else
- cat << \SHAR_EOF > 'tty/ansi/ttydef.h'
- /*
- * Name: MicroEMACS
- * Digital ANSI terminal header file
- * Version: 29
- * Last edit: 05-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #define GOSLING 1 /* Compile in fancy display. */
- #define MEMMAP 0 /* Not memory mapped video. */
-
- /*
- * Yes Bob, it's wrong for you.
- */
- #define NROW 66 /* Rows. */
- #define NCOL 132 /* Columns. */
-
- /*
- * Special keys, as on the LK201, which is
- * a superset of the VT100. Originally I tried to keep the
- * numbers in LK201 escape sequence code, but it became too much
- * of a pain because of the keycodes greater than 31.
- * The codes are all just redefinitions for the standard extra
- * key codes. Using the standard names ensures that the
- * LK201 codes land in the right place.
- */
- #define KUP K01
- #define KDOWN K02
- #define KLEFT K03
- #define KRIGHT K04
- #define KFIND K05
- #define KINSERT K06
- #define KREMOVE K07
- #define KSELECT K08
- #define KPREV K09
- #define KNEXT K0A
- #define KF4 K0B
- #define KF6 K0C
- #define KF7 K0D
- #define KF8 K0E
- #define KF9 K0F
- #define KF10 K10
- #define KF11 K11
- #define KF12 K12
- #define KF13 K13
- #define KF14 K14
- #define KHELP K15
- #define KDO K16
- #define KF17 K17
- #define KF18 K18
- #define KF19 K19
- #define KF20 K1A
- #define KPF1 K1B
- #define KPF2 K1C
- #define KPF3 K1D
- #define KPF4 K1E
- SHAR_EOF
- if test 1285 -ne "`wc -c < 'tty/ansi/ttydef.h'`"
- then
- echo shar: error transmitting "'tty/ansi/ttydef.h'" '(should have been 1285 characters)'
- fi
- fi
- echo shar: extracting "'tty/ansi/ttykbd.c'" '(4152 characters)'
- if test -f 'tty/ansi/ttykbd.c'
- then
- echo shar: will not over-write existing file "'tty/ansi/ttykbd.c'"
- else
- cat << \SHAR_EOF > 'tty/ansi/ttykbd.c'
- /*
- * Name: MicroEMACS
- * Digital ANSI terminal keyboard.
- * Assumes LK201, which is OK on the VT100.
- * Version: 29
- * Last edit: 05-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #include "def.h"
-
- #define ESC 0x1B /* Escape, arrows et al. */
- #define AGRAVE 0x60 /* LK201 kludge. */
-
- /*
- * The special keys on an LK201 send back
- * escape sequences of the general form <ESC>[nnn~, where
- * nnn is a key code number. This table is indexed by the
- * nnn code to get the key code, which is used in the
- * binding table. The F4 key, and the F6 through F14 keys
- * have key codes. Also F17 through F20. Think of
- * help and do as special.
- */
- short lk201map[] = {
- KRANDOM, KFIND, KINSERT, KREMOVE,
- KSELECT, KPREV, KNEXT, KRANDOM,
- KRANDOM, KRANDOM, KRANDOM, KRANDOM,
- KRANDOM, KRANDOM, KF4, KRANDOM,
- KRANDOM, KF6, KF7, KF8,
- KF9, KF10, KRANDOM, KF11,
- KF12, KF13, KF14, KRANDOM,
- KHELP, KDO, KRANDOM, KF17,
- KF18, KF19, KF20
- };
-
- /*
- * Names for the keys with basic keycode
- * between KFIRST and KLAST (inclusive). This is used by
- * the key name routine in "kbd.c".
- */
- char *keystrings[] = {
- NULL, "Up", "Down", "Left",
- "Right", "Find", "Insert", "Remove",
- "Select", "Previous", "Next", "F4",
- "F6", "F7", "F8", "F9",
- "F10", "F11", "F12", "F13",
- "F14", "Help", "Do", "F17",
- "F18", "F19", "F20", "PF1",
- "PF2", "PF3", "PF4", NULL
- };
-
- /*
- * Read in a key, doing the low level mapping
- * of ASCII code to 11 bit code. This level deals with
- * mapping the special keys into their spots in the C1
- * control area. The C0 controls go right through, and
- * get remapped by "getkey".
- */
- getkbd()
- {
- register int c;
- register int n;
- loop:
- c = ttgetc();
- if (c == AGRAVE) /* On LK201, grave is */
- c = METACH; /* also META. */
- if (c == ESC) {
- c = ttgetc();
- if (c == '[') {
- c = ttgetc();
- if (c == 'A')
- return (KUP);
- if (c == 'B')
- return (KDOWN);
- if (c == 'C')
- return (KRIGHT);
- if (c == 'D')
- return (KLEFT);
- if (c>='0' && c<='9') { /* LK201 functions. */
- n = 0;
- do {
- n = 10*n + c - '0';
- c = ttgetc();
- } while (c>='0' && c<='9');
- if (c=='~' && n<=34) {
- c = lk201map[n];
- if (c != KRANDOM)
- return (c);
- goto loop;
- }
- }
- goto loop;
- }
- if (c == 'O') {
- c = ttgetc();
- if (c == 'A')
- return (KUP);
- if (c == 'B')
- return (KDOWN);
- if (c == 'C')
- return (KRIGHT);
- if (c == 'D')
- return (KLEFT);
- if (c == 'P')
- return (KPF1);
- if (c == 'Q')
- return (KPF2);
- if (c == 'R')
- return (KPF3);
- if (c == 'S')
- return (KPF4);
- goto loop;
- }
- if (ISLOWER(c) != FALSE) /* Copy the standard */
- c = TOUPPER(c); /* META code. */
- if (c>=0x00 && c<=0x1F)
- c = KCTRL | (c+'@');
- return (KMETA | c);
- }
- return (c);
- }
-
- /*
- * Terminal specific keymap initialization.
- * Attach the special keys to the appropriate built
- * in functions. Bind all of the assigned graphics in the
- * DEC supplimental character set to "ins-self".
- * As is the case of all the keymap routines, errors
- * are very fatal.
- */
- ttykeymapinit()
- {
- register SYMBOL *sp;
- register int i;
-
- keydup(KFIND, "search-again");
- keydup(KHELP, "help");
- keydup(KINSERT, "yank");
- keydup(KREMOVE, "kill-region");
- keydup(KSELECT, "set-mark");
- keydup(KPREV, "back-page");
- keydup(KNEXT, "forw-page");
- keydup(KDO, "execute-macro");
- keydup(KF17, "back-window");
- keydup(KF18, "forw-window");
- keydup(KF19, "enlarge-window");
- keydup(KF20, "shrink-window");
- keydup(KUP, "back-line");
- keydup(KDOWN, "forw-line");
- keydup(KRIGHT, "forw-char");
- keydup(KLEFT, "back-char");
-
- /*
- * Bind all GR positions that correspond
- * to assigned characters in the Digital multinational
- * character set to "ins-self". These characters may
- * be used just like any other character.
- */
-
- if ((sp=symlookup("ins-self")) == NULL)
- abort();
- for (i=0xA0; i<0xFF; ++i) {
- if (i!=0xA4 && i!=0xA6 && i!=0xAC && i!=0xAD && i!=0xAE
- && i!=0xAF && i!=0xB4 && i!=0xB8 && i!=0xBE && i!=0xF0
- && i!=0xFE && i!=0xA0) {
- if (binding[i] != NULL)
- abort();
- binding[i] = sp;
- ++sp->s_nkey;
- }
- }
- }
- SHAR_EOF
- if test 4152 -ne "`wc -c < 'tty/ansi/ttykbd.c'`"
- then
- echo shar: error transmitting "'tty/ansi/ttykbd.c'" '(should have been 4152 characters)'
- fi
- fi
- echo shar: done with directory "'tty/ansi'"
- if test ! -d 'tty/atari'
- then
- echo shar: creating directory "'tty/atari'"
- mkdir 'tty/atari'
- fi
- echo shar: extracting "'tty/atari/tty.c'" '(2927 characters)'
- if test -f 'tty/atari/tty.c'
- then
- echo shar: will not over-write existing file "'tty/atari/tty.c'"
- else
- cat << \SHAR_EOF > 'tty/atari/tty.c'
- /*
- * Name: MicroEMACS
- * Atari 520ST terminal.
- * Version: 30
- * Last edit: 22-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- *
- * This code simulates scrolling regions by using the
- * insert line and delete line functions. Should display
- * handling be taught about this. Based on Rich's code
- * for the Heath H19.
- */
- #include "def.h"
-
- #define BEL 0x07 /* BEL character. */
- #define ESC 0x1B /* ESC character. */
- #define LF 0x0A /* Line feed. */
-
- extern int ttrow;
- extern int ttcol;
- extern int tttop;
- extern int ttbot;
- extern int tthue;
-
- int tceeol = 2; /* Costs. */
- int tcinsl = 11;
- int tcdell = 11;
-
- /*
- * No-op.
- */
- ttinit()
- {
- }
-
- /*
- * No-op.
- */
- tttidy()
- {
- }
-
- /*
- * Move the cursor to the specified
- * origin 0 row and column position. Try to
- * optimize out extra moves; redisplay may
- * have left the cursor in the right location
- * on the screen last time.
- */
- ttmove(row, col)
- {
- if (ttrow!=row || ttcol!=col) {
- if (row > nrow)
- row = nrow;
- if (col > ncol)
- col = ncol;
- ttputc(ESC);
- ttputc('Y');
- ttputc(row+' ');
- ttputc(col+' ');
- ttrow = row;
- ttcol = col;
- }
- }
-
- /*
- * Erase to end of line.
- */
- tteeol()
- {
- ttputc(ESC);
- ttputc('K');
- }
-
- /*
- * Erase to end of page.
- */
- tteeop()
- {
- ttputc(ESC);
- ttputc('J');
- }
-
- /*
- * Make a noise.
- */
- ttbeep()
- {
- ttputc(BEL);
- ttflush();
- }
-
- /*
- * Insert nchunk blank line(s) onto the
- * screen, scrolling the last line on the
- * screen off the bottom. This is done with
- * a cluster of clever insert and delete commands,
- * because there are no scroll regions.
- */
- ttinsl(row, bot, nchunk)
- {
- register int i;
-
- if (row == bot) {
- ttmove(row, 0);
- tteeol();
- return;
- }
- ttmove(1+bot-nchunk, 0);
- for (i=0; i<nchunk; i++) {
- ttputc(ESC);
- ttputc('M');
- }
- ttmove(row, 0);
- for (i=0; i<nchunk; i++) {
- ttputc(ESC);
- ttputc('L');
- }
- ttrow = row;
- ttcol = 0;
- }
-
- /*
- * Delete nchunk line(s) "row", replacing the
- * bottom line on the screen with a blank
- * line. This is done with a crafty sequences
- * of insert and delete line; there is no scroll
- * region on the Heath. The presence of the
- * echo area makes a boundry condition
- * go away.
- */
- ttdell(row, bot, nchunk)
- {
- register int i;
-
- if (row == bot) {
- ttmove(row, 0);
- tteeol();
- return;
- }
- ttmove(row, 0);
- for (i=0; i<nchunk; i++) {
- ttputc(ESC);
- ttputc('M');
- }
- ttmove(1+bot-nchunk,0);
- for (i=0; i<nchunk; i++) {
- ttputc(ESC);
- ttputc('L');
- }
- ttrow = bot-nchunk;
- ttcol = 0;
- }
-
- /*
- * No-op.
- */
- ttwindow(top, bot)
- {
- }
-
- /*
- * No-op.
- */
- ttnowindow()
- {
- }
-
- /*
- * Set display color on Heath. Normal
- * video is text color. Reverse video is used for
- * the mode line.
- */
- ttcolor(color)
- register int color;
- {
- if (color != tthue) {
- if (color == CTEXT) { /* Normal video. */
- ttputc(ESC);
- ttputc('q');
- } else if (color == CMODE) { /* Reverse video. */
- ttputc(ESC);
- ttputc('p');
- }
- tthue = color;
- }
- }
-
- /*
- * No-op.
- */
- ttresize()
- {
- }
- SHAR_EOF
- if test 2927 -ne "`wc -c < 'tty/atari/tty.c'`"
- then
- echo shar: error transmitting "'tty/atari/tty.c'" '(should have been 2927 characters)'
- fi
- fi
- echo shar: extracting "'tty/atari/ttydef.h'" '(691 characters)'
- if test -f 'tty/atari/ttydef.h'
- then
- echo shar: will not over-write existing file "'tty/atari/ttydef.h'"
- else
- cat << \SHAR_EOF > 'tty/atari/ttydef.h'
- /*
- * Name: MicroEMACS
- * Atari 520ST header file.
- * Version: 30
- * Last edit: 22-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #define GOSLING 1 /* Use fancy redisplay. */
- #define MEMMAP 0 /* Not memory mapped video. */
-
- #define NROW 50 /* The "50" is big enough to */
- #define NCOL 80 /* deal with the "hi50" screen. */
-
- /*
- * Special keys.
- */
- #define KF1 K01
- #define KF2 K02
- #define KF3 K03
- #define KF4 K04
- #define KF5 K05
- #define KF6 K06
- #define KF7 K07
- #define KF8 K08
- #define KF9 K09
- #define KF10 K0A
- #define KHELP K0B
- #define KUNDO K0C
- #define KINSERT K0D
- #define KUP K0E
- #define KCLEAR K0F
- #define KLEFT K10
- #define KDOWN K11
- #define KRIGHT K12
- SHAR_EOF
- if test 691 -ne "`wc -c < 'tty/atari/ttydef.h'`"
- then
- echo shar: error transmitting "'tty/atari/ttydef.h'" '(should have been 691 characters)'
- fi
- fi
- echo shar: extracting "'tty/atari/ttykbd.c'" '(2018 characters)'
- if test -f 'tty/atari/ttykbd.c'
- then
- echo shar: will not over-write existing file "'tty/atari/ttykbd.c'"
- else
- cat << \SHAR_EOF > 'tty/atari/ttykbd.c'
- /*
- * Name: MicroEMACS
- * Atari 520ST keyboard.
- * Version: 30
- * Last edit: 22-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #include "def.h"
- #include <osbind.h>
-
- /*
- * Key names.
- */
- char *keystrings[] = {
- NULL, "F1", "F2", "F3",
- "F4", "F5", "F6", "F7",
- "F8", "F9", "F10", "Help",
- "Undo", "Insert", "Up", "Clr/Home",
- "Left", "Down", "Right", NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL
- };
-
- /*
- * This function is used to read the
- * keyboard for the first time. A call to the system
- * is made directly, to see the 32 bit key code. If the
- * scan code says this is a function key, remap the
- * codes. I might want to make the "Alt" key work like
- * a "Meta" key, by looking at scan code.
- */
- getkbd()
- {
- register long rawkey;
- register int k;
-
- rawkey = Crawcin();
- k = (rawkey>>16) & 0xFF; /* Scan code. */
- if (k == 0x3B)
- return (KF1);
- if (k == 0x3C)
- return (KF2);
- if (k == 0x3D)
- return (KF3);
- if (k == 0x3E)
- return (KF4);
- if (k == 0x3F)
- return (KF5);
- if (k == 0x40)
- return (KF6);
- if (k == 0x41)
- return (KF7);
- if (k == 0x42)
- return (KF8);
- if (k == 0x43)
- return (KF9);
- if (k == 0x44)
- return (KF10);
- if (k == 0x62)
- return (KHELP);
- if (k == 0x61)
- return (KUNDO);
- if (k == 0x52)
- return (KINSERT);
- if (k == 0x48)
- return (KUP);
- if (k == 0x47)
- return (KCLEAR);
- if (k == 0x4B)
- return (KLEFT);
- if (k == 0x50)
- return (KDOWN);
- if (k == 0x4D)
- return (KRIGHT);
- return ((int)(rawkey&0x7F));
- }
-
- /*
- * Establish default keypad
- * bindings. The "Undo" key is bound to the
- * "execute-macro"; this is where I bind "Do" on
- * an LK201, and it is very handy.
- * All of the Fn keys are bindable, but there
- * are no default bindings.
- */
- ttykeymapinit()
- {
- keydup(KHELP, "help");
- keydup(KUNDO, "execute-macro");
- keydup(KINSERT, "yank");
- keydup(KUP, "back-line");
- keydup(KCLEAR, "kill-region");
- keydup(KLEFT, "back-char");
- keydup(KDOWN, "forw-line");
- keydup(KRIGHT, "forw-char");
- }
- SHAR_EOF
- if test 2018 -ne "`wc -c < 'tty/atari/ttykbd.c'`"
- then
- echo shar: error transmitting "'tty/atari/ttykbd.c'" '(should have been 2018 characters)'
- fi
- fi
- echo shar: done with directory "'tty/atari'"
- if test ! -d 'tty/heath'
- then
- echo shar: creating directory "'tty/heath'"
- mkdir 'tty/heath'
- fi
- echo shar: extracting "'tty/heath/tty.c'" '(3530 characters)'
- if test -f 'tty/heath/tty.c'
- then
- echo shar: will not over-write existing file "'tty/heath/tty.c'"
- else
- cat << \SHAR_EOF > 'tty/heath/tty.c'
- /*
- * Name: MicroEMACS
- * Heath H19 display
- * Version: 29
- * Last edit: 10-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- *
- * This code simulates scrolling regions by using the
- * insert line and delete line functions. Should display
- * handling be told about this?
- * This is code is by Rich Ellison. A man always does
- * the support for the terminal he owns.
- */
- #include "def.h"
-
- #define BEL 0x07 /* BEL character. */
- #define ESC 0x1B /* ESC character. */
- #define LF 0x0A /* Line feed. */
-
- extern int ttrow;
- extern int ttcol;
- extern int tttop;
- extern int ttbot;
- extern int tthue;
-
- int tceeol = 2; /* Costs. */
- int tcinsl = 11;
- int tcdell = 11;
-
- /*
- * The Heath needs no initialization.
- */
- ttinit()
- {
- }
-
- /*
- * The Heath needs no tidy up.
- */
- tttidy()
- {
- }
-
- /*
- * Move the cursor to the specified
- * origin 0 row and column position. Try to
- * optimize out extra moves; redisplay may
- * have left the cursor in the right
- * location last time!
- */
- ttmove(row, col)
- {
- if (ttrow!=row || ttcol!=col) {
- if (row > NROW)
- row = NROW;
- if (col > NCOL)
- col = NCOL;
- ttputc(ESC);
- ttputc('Y');
- ttputc(row+' ');
- ttputc(col+' ');
- ttrow = row;
- ttcol = col;
- }
- }
-
- /*
- * Erase to end of line.
- */
- tteeol()
- {
- ttputc(ESC);
- ttputc('K');
- }
-
- /*
- * Erase to end of page.
- */
- tteeop()
- {
- ttputc(ESC);
- ttputc('J');
- }
-
- /*
- * Make a noise.
- */
- ttbeep()
- {
- ttputc(BEL);
- ttflush();
- }
-
- /*
- * Insert nchunk blank line(s) onto the
- * screen, scrolling the last line on the
- * screen off the bottom. This is done with
- * a cluster of clever insert and delete commands,
- * because there are no scroll regions.
- */
- ttinsl(row, bot, nchunk)
- {
- register int i;
-
- if (row == bot) { /* Case of one line insert is */
- ttmove(row, 0); /* special */
- tteeol();
- return;
- }
- ttmove(1+bot-nchunk, 0);
- for (i=0; i<nchunk; i++) { /* For all lines in the chunk */
- ttputc(ESC); /* DEL current line, anything */
- ttputc('M'); /* below moves up. */
- }
- ttmove(row, 0);
- for (i=0; i<nchunk; i++) { /* For all lines in the chunk */
- ttputc(ESC); /* INS before current line, */
- ttputc('L'); /* sliding stuff down. */
- }
- ttrow = row; /* End up on current line */
- ttcol = 0;
- }
-
- /*
- * Delete nchunk line(s) "row", replacing the
- * bottom line on the screen with a blank
- * line. This is done with a crafty sequences
- * of insert and delete line; there is no scroll
- * region on the Heath. The presence of the
- * echo area makes a boundry condition
- * go away.
- */
- ttdell(row, bot, nchunk)
- {
- register int i;
-
- if (row == bot) { /* One line special case */
- ttmove(row, 0);
- tteeol();
- return;
- }
- ttmove(row, 0);
- for (i=0; i<nchunk; i++) { /* For all lines in chunk */
- ttputc(ESC); /* DEL top line, lines below */
- ttputc('M'); /* all move up. */
- }
- ttmove(1+bot-nchunk,0);
- for (i=0; i<nchunk; i++) { /* For all lines in chunk */
- ttputc(ESC); /* INS line before botton, */
- ttputc('L'); /* all lines move down. */
- }
- ttrow = bot-nchunk;
- ttcol = 0;
- }
-
- /*
- * No-op.
- */
- ttwindow(top, bot)
- {
- }
-
- /*
- * No-op.
- */
- ttnowindow()
- {
- }
-
- /*
- * Set display color on Heath. Normal
- * video is text color. Reverse video is used for
- * the mode line. Rich knew the sequences for the
- * Heath by heart.
- */
- ttcolor(color)
- register int color;
- {
- if (color != tthue) {
- if (color == CTEXT) { /* Normal video. */
- ttputc(ESC);
- ttputc('q');
- } else if (color == CMODE) { /* Reverse video. */
- ttputc(ESC);
- ttputc('p');
- }
- tthue = color;
- }
- }
-
- /*
- * No-op.
- */
- ttresize()
- {
- }
- SHAR_EOF
- if test 3530 -ne "`wc -c < 'tty/heath/tty.c'`"
- then
- echo shar: error transmitting "'tty/heath/tty.c'" '(should have been 3530 characters)'
- fi
- fi
- echo shar: extracting "'tty/heath/ttydef.h'" '(352 characters)'
- if test -f 'tty/heath/ttydef.h'
- then
- echo shar: will not over-write existing file "'tty/heath/ttydef.h'"
- else
- cat << \SHAR_EOF > 'tty/heath/ttydef.h'
- /*
- * Name: MicroEMACS
- * Heath H19 header file
- * Version: 29
- * Last edit: 05-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #define GOSLING 1 /* Use fancy redisplay. */
- #define MEMMAP 0 /* Not memory mapped video. */
-
- #define NROW 24 /* Use line 25? The only H19 I */
- #define NCOL 80 /* used had line 25 bugs. */
- SHAR_EOF
- if test 352 -ne "`wc -c < 'tty/heath/ttydef.h'`"
- then
- echo shar: error transmitting "'tty/heath/ttydef.h'" '(should have been 352 characters)'
- fi
- fi
- echo shar: extracting "'tty/heath/ttykbd.c'" '(679 characters)'
- if test -f 'tty/heath/ttykbd.c'
- then
- echo shar: will not over-write existing file "'tty/heath/ttykbd.c'"
- else
- cat << \SHAR_EOF > 'tty/heath/ttykbd.c'
- /*
- * Name: MicroEMACS
- * Heath H19 keyboard
- * Version: 29
- * Last edit: 05-Feb-86
- * By: rex::conroy
- * decvax!decwrl!dec-rhea!dec-rex!conroy
- */
- #include "def.h"
-
- /*
- * Empty key name table.
- */
- char *keystrings[] = {
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL
- };
-
- /*
- * Get keyboard character, and interpret
- * any special keys on the keyboard. This is really
- * easy, because there arn't any special keys.
- */
- getkbd()
- {
- return (ttgetc());
- }
-
- /*
- * No special keys.
- */
- ttykeymapinit()
- {
- }
- SHAR_EOF
- if test 679 -ne "`wc -c < 'tty/heath/ttykbd.c'`"
- then
- echo shar: error transmitting "'tty/heath/ttykbd.c'" '(should have been 679 characters)'
- fi
- fi
- echo shar: done with directory "'tty/heath'"
- echo shar: done with directory "'tty'"
- exit 0
- # End of shell archive
-